package compilers.stmt;

import java.io.BufferedWriter;
import java.io.IOException;

import compilers.node.Stmt;
import compilers.table.MemScope;

public class Keyword extends Stmt {
	String fKeyword;
	
	public Keyword(String fKeyword) {
		super();
		this.fKeyword = fKeyword;
	}

	@Override
	public void print(int tab) {
		for (int i=1;i<=tab;i++){System.out.print("\t");}System.out.print("|-");
		System.out.println("Keyword (" + fKeyword + ")");
	}

	@Override
	public void generate(BufferedWriter writer, MemScope scope) throws IOException {
		String lbl = scope.getLastLoopLabel();
		if(fKeyword == "break") {
			writer.write("ujp end_while_" + lbl + "\n" );
		} else if(fKeyword == "continue") {
			writer.write("ujp while_" + lbl + "\n" );
		}
	}

}
